First Agent
In BindAI, an Agent is a core building block for AI applications. An agent can combine:- A language model provider
- Instructions
- Tools
- Memory
- Knowledge
- Retrieval
- Conversation context
- Execution configuration
- Middleware
- Hooks and callbacks
- Events
Creating an Agent
The recommended way to configure an agent is throughAgent.builder().
run() method executes the agent and returns an AgentResult.
Agent Builder
Agent.builder() provides a fluent API for configuring an agent.
The builder allows an application to compose an agent incrementally without manually constructing every supporting component.
Configuring a Model
A model can be configured using a provider-prefixed model identifier.Provider Configuration
BindAI separates agent configuration from the underlying model provider. Providers are registered through the BindAI provider system and can be selected using provider-prefixed model identifiers. This allows the same agent architecture to work with different model providers without changing the surrounding application structure. Current provider integrations include:- OpenAI
- Anthropic
- Google Gemini
- Groq
- Ollama
- OpenRouter
Sending Prompts
The primary execution method isrun().
AgentResult.
The generated output can be accessed through:
Chat and Conversation
BindAI agents can work with conversation state and conversational memory. A conversation-aware application can maintain previous interactions and use them as context for subsequent execution. The exact conversation behavior depends on the agent’s configured conversation and memory components. For applications that need persistent conversational state, configure an appropriate memory provider.Structured Output
BindAI supports structured execution through its provider and execution abstractions. When using a provider that supports structured responses, an application can request output conforming to a defined Python type. For example, a Pydantic model can define the desired structure:Provider support for specific structured-output features can vary. Always verify the capabilities of the model provider you are using.
Streaming
Agents also support streaming execution. Streaming is useful when an application needs incremental output instead of waiting for the complete execution result. For example:- Interactive chat interfaces
- Long-running responses
- Incremental output processing
- Real-time application interfaces
Adding Tools
Tools allow an agent to perform actions through Python functions or other tool implementations. A simple tool can be created with BindAI’stool decorator:
Tool Registry
BindAI includes a tool registry and execution system for managing agent tools. This separates tool definition from agent execution and allows applications to organize reusable capabilities. A tool can represent:- A Python function
- An external API
- A database operation
- A search operation
- An application service
- An external connection
- An MCP-backed capability
Adding Memory
Memory allows agents to retain information across interactions. Memory can be supplied through the agent configuration:- In-memory memory
- SQLite
- PostgreSQL
- Vector memory
- Pinecone
- Chroma
Adding Knowledge
Knowledge allows an agent to use application-specific information during execution. A knowledge component can be supplied through the agent configuration:- Document ingestion
- Parsing
- Chunking
- Embeddings
- Metadata
- Semantic retrieval
- BM25 retrieval
- Hybrid retrieval
- Filtering
- Reranking
- Conversational retrieval
- Knowledge pipelines
Adding a Retriever
Retrieval components can be configured for agents that need direct access to retrieved information. For example:- Vector retrieval
- BM25 retrieval
- Hybrid retrieval
Middleware
Middleware provides a mechanism for applying cross-cutting behavior around agent execution. Middleware can be configured when building an agent:- Logging
- Request processing
- Output processing
- Metrics
- Validation
- Other execution concerns
Events, Hooks, and Callbacks
BindAI provides event and lifecycle mechanisms around agent execution. Agents can work with an event bus and execution hooks to observe or customize execution behavior. Typical use cases include:- Logging execution
- Monitoring agent activity
- Recording execution results
- Handling errors
- Adding application-specific lifecycle behavior
Execution Configuration
Agent execution can be configured independently from the agent’s core model configuration. Execution configuration can control aspects of how the agent operates, including behavior around:- Tool execution
- Context
- Memory
- Knowledge retrieval
- Middleware
- Execution lifecycle
Agent Context
Agents can operate with execution context containing information needed during an agent run. Context can connect the agent with application state and supporting execution components. This is particularly useful when an agent is part of a larger workflow or multi-agent application. For example:Agent Delegation
BindAI agents can delegate work to other agents. Delegation is useful when a larger application is divided into specialized responsibilities. For example:RAG-Enabled Agents
Agents can combine knowledge and retrieval with model execution. A typical RAG-enabled agent follows this flow:Agents in Workflows
Agents do not have to operate independently. They can be used as execution steps inside BindAI workflows. For example:- Conditions
- Loops
- Parallel execution
- Retries
- Timeouts
- Scheduling
- Human tasks
Direct Agent Construction
TheAgent class is also publicly available:
Agent.builder() is the more convenient approach because it provides a fluent configuration interface.
Complete Basic Example
A minimal BindAI agent can be configured as follows:Agent Development Flow
The typical development process is:- Choose a model provider.
- Configure the agent.
- Add instructions.
- Add tools when actions are required.
- Add memory when conversation state is required.
- Add knowledge or retrieval when application-specific information is required.
- Add middleware or hooks for cross-cutting execution behavior.
- Integrate the agent into a workflow when multi-step orchestration is required.
- Use delegation when responsibilities should be distributed across multiple agents.
- Test the complete application.
